<?php
!defined('P_W') && exit('Forbidden');

require_once(R_P . 'lib/upload.class.php');

class ImageUpload extends uploadBehavior {
	var $attachs;
	var $hid;
	var $miniPath;
	var $naturePath;

	function ImageUpload($hid,$naturePath,$miniPath) {
		parent::uploadBehavior();
		$this->ifftp = 0;
		$this->hid = $hid;
		$this->naturePath = $naturePath;
		$this->miniPath = $miniPath;
		
		$this->ftype = $this->getFtype();
	}
	
	function getFtype() {
		$db_imgsize = 2000;
		return array(
			'gif'  => $db_imgsize,				'jpg'  => $db_imgsize,
			'jpeg' => $db_imgsize,				'bmp'  => $db_imgsize,
			'png'  => $db_imgsize
		);
	}

	function allowType($key) {
		return true;
	}
	function allowThumb() {
		return true;
	}
	
	function getThumbSize() {
		return "100\t100";
	}

	function getFilePath($currUpload) {
		global $timestamp;
		$filename = $timestamp.substr(md5($timestamp . $currUpload['name'] . randstr(8) ),10,5) . '.' . $currUpload['ext'];
		$savedir = $this->naturePath.$this->hid.'/';
		$minisave = $this->miniPath.$this->hid.'/';
		return array($filename, $savedir, $filename, $minisave);
	}

	function update($uploaddb) {
		$this->attachs = $uploaddb;
	}

	function getAttachs() {
		return $this->attachs;
	}
}
?>